package com.appwoo.txtws.service;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.ParseException;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.bean.LoginBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.PhoneHelper;
import com.appwoo.txtws.component.RqSP;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

public class RQKeepAlive
{
  public static RQKeepAlive instance;
  private String pass;
  private String userName;

  private void clearSenPho(Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("firstLogin", 0).edit();
    localEditor.putString("rqtime", "1900-01-01 00:00:00");
    boolean bool = localEditor.commit();
    if (bool)
    {
      DBHelper localDBHelper = new DBHelper(paramContext);
      localDBHelper.clearSeniorTime();
      localDBHelper.clearNotify();
      localDBHelper.clearLeavesAndHoliday();
      new PhoneHelper(paramContext).clearData();
    }
    Logger.e("admin", "sky_keepAlive：清空本地高级时间+亲情电话-公告通知-请假条-节假日" + bool);
  }

  public static RQKeepAlive getInstance()
  {
    if (instance == null)
      instance = new RQKeepAlive();
    return instance;
  }

  public void call(Context paramContext)
  {
    while (true)
    {
      try
      {
        LoginBean localLoginBean = new DBHelper(paramContext).getLogin();
        if (localLoginBean != null)
        {
          Global.USERNAME = localLoginBean.getUsername();
          if (localLoginBean.getPassword() != null)
            Global.PASSWORD = localLoginBean.getPassword();
          Global.isBinded = Integer.parseInt(localLoginBean.getIsBind());
        }
        SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("firstLogin", 0);
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        Global.deptId = localSharedPreferences.getString("deptId", "-1");
        String str1 = localSharedPreferences.getString("rqtime", null);
        String str2 = Global.getTodayDate(paramContext);
        if ((str1 == null) || ((!str1.split(" ")[0].equals(str2)) && (!str1.equals("1900-01-01 00:00:00"))))
        {
          str1 = "1900-01-01 00:00:00";
          clearSenPho(paramContext);
          new RQUpdate().deleFile(paramContext);
        }
        StateBean localStateBean = new LoginService().KeepAliveSky(Global.USERNAME, Global.getIMEI(paramContext), str1, paramContext);
        Logger.i("admin", localStateBean.getCode() + "-keepalive---");
        if (localStateBean.getCode().equals("0"))
        {
          if ((localStateBean.getLsRqTime() != null) && (!localStateBean.getLsRqTime().equals("")))
          {
            String str4 = localStateBean.getLsRqTime();
            Logger.i("admin", "下次访问时间:" + str4);
            localEditor.putString("rqtime", str4);
            localEditor.commit();
          }
          if (localStateBean.getManageType() != null)
          {
            if (!localStateBean.getManageType().equalsIgnoreCase("School"))
              break label851;
            i = 1;
            if ((Global.isSchool != -1) && (Global.isSchool != i))
            {
              clearSenPho(paramContext);
              WebTimeControlService.ut = -1L;
            }
            Global.isSchool = i;
            localEditor.putInt("isSchool", Global.isSchool);
            localEditor.commit();
          }
          if (localStateBean.getDeptId() != null)
          {
            String str3 = localStateBean.getDeptId();
            if (!Global.deptId.equals(str3))
            {
              localEditor.putString("deptId", str3);
              localEditor.commit();
              if (!"-1".equals(Global.deptId))
              {
                clearSenPho(paramContext);
                Global.isDeptIdChange = true;
              }
              Global.deptId = str3;
            }
          }
          if ((localStateBean.getDeptName() != null) && (!localStateBean.getDeptName().equals("")))
          {
            Global.deptName = localStateBean.getDeptName();
            localEditor.putString("deptName", Global.deptName);
            localEditor.commit();
          }
          if ((localStateBean.getStuName() != null) && (!localStateBean.getStuName().equals("")))
          {
            Global.stuName = localStateBean.getStuName();
            localEditor.putString("stuName", Global.stuName);
            localEditor.commit();
          }
          Logger.i("admin", "deptId:" + Global.deptId + "\tdeptName:" + Global.deptName + "\tstuName:" + Global.stuName);
          new RQNetLock(paramContext).getTodayNet(localStateBean);
          if (!Global.doubleLock)
            new RQScreenLock(paramContext).getTodayScreen(localStateBean);
          new RQLocation(paramContext).rqSwitch(localStateBean);
          new DBHelper(paramContext).updateLoginPwd(Global.USERNAME, localStateBean.getPwd());
          if (localStateBean.getPwd() != null)
          {
            new RqSP().setParentPwd(localStateBean.getPwd(), paramContext);
            Global.PASSWORD = localStateBean.getPwd();
          }
        }
        else
        {
          Logger.i("admin", "未同步到服务器时间");
          return;
        }
      }
      catch (IOException localIOException)
      {
        Logger.e("admin", "sky_keepAlive " + localIOException.toString());
        localIOException.printStackTrace();
        return;
      }
      catch (XmlPullParserException localXmlPullParserException)
      {
        localXmlPullParserException.printStackTrace();
        Logger.e("admin", "sky_keepAlive " + localXmlPullParserException.toString());
        return;
      }
      catch (TimeOutException localTimeOutException)
      {
        localTimeOutException.printStackTrace();
        Logger.e("admin", "sky_keepAlive time out exception");
        return;
      }
      catch (NotFoundNetWorkException localNotFoundNetWorkException)
      {
        localNotFoundNetWorkException.printStackTrace();
        Logger.e("admin", "sky_keepAlive NotFoundNetWorkException");
        return;
      }
      catch (ParseException localParseException)
      {
        localParseException.printStackTrace();
        Logger.e("admin", "sky_keepAlive " + localParseException.toString());
        return;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        Logger.e("admin", "sky_keepAlive " + localException.toString());
      }
      return;
      label851: int i = 0;
    }
  }

  // ERROR //
  public java.util.List<StateBean> callKeep(Context paramContext)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: ldc 17
    //   4: iconst_0
    //   5: invokevirtual 23	android/content/Context:getSharedPreferences	(Ljava/lang/String;I)Landroid/content/SharedPreferences;
    //   8: ldc_w 319
    //   11: ldc 205
    //   13: invokeinterface 145 3 0
    //   18: putfield 321	com/appwoo/txtws/service/RQKeepAlive:userName	Ljava/lang/String;
    //   21: aload_1
    //   22: ldc_w 323
    //   25: iconst_0
    //   26: invokevirtual 23	android/content/Context:getSharedPreferences	(Ljava/lang/String;I)Landroid/content/SharedPreferences;
    //   29: ldc_w 323
    //   32: ldc 205
    //   34: invokeinterface 145 3 0
    //   39: astore_2
    //   40: ldc 205
    //   42: astore_3
    //   43: aload_0
    //   44: getfield 321	com/appwoo/txtws/service/RQKeepAlive:userName	Ljava/lang/String;
    //   47: invokestatic 329	com/appwoo/txtws/component/CrypHelper:des3DedoceCBCString	(Ljava/lang/String;)Ljava/lang/String;
    //   50: astore 12
    //   52: aload 12
    //   54: astore_3
    //   55: new 173	com/appwoo/txtws/service/LoginService
    //   58: dup
    //   59: invokespecial 174	com/appwoo/txtws/service/LoginService:<init>	()V
    //   62: aload_3
    //   63: aload_2
    //   64: aload_1
    //   65: invokevirtual 333	com/appwoo/txtws/service/LoginService:KeepAliveS	(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)Ljava/util/List;
    //   68: astore 11
    //   70: aload 11
    //   72: astore 6
    //   74: aload 6
    //   76: areturn
    //   77: astore 4
    //   79: aload 4
    //   81: ifnull -26 -> 55
    //   84: aload 4
    //   86: invokevirtual 314	java/lang/Exception:printStackTrace	()V
    //   89: goto -34 -> 55
    //   92: astore 10
    //   94: aconst_null
    //   95: astore 6
    //   97: aload 10
    //   99: ifnull -25 -> 74
    //   102: aload 10
    //   104: invokevirtual 303	java/io/IOException:printStackTrace	()V
    //   107: ldc 65
    //   109: ldc_w 335
    //   112: invokestatic 198	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   115: aconst_null
    //   116: areturn
    //   117: astore 9
    //   119: aconst_null
    //   120: astore 6
    //   122: aload 9
    //   124: ifnull -50 -> 74
    //   127: aload 9
    //   129: invokevirtual 304	org/xmlpull/v1/XmlPullParserException:printStackTrace	()V
    //   132: ldc 65
    //   134: ldc_w 337
    //   137: invokestatic 198	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   140: aconst_null
    //   141: areturn
    //   142: astore 8
    //   144: aconst_null
    //   145: astore 6
    //   147: aload 8
    //   149: ifnull -75 -> 74
    //   152: aload 8
    //   154: invokevirtual 306	com/appwoo/android/exception/TimeOutException:printStackTrace	()V
    //   157: ldc 65
    //   159: ldc_w 339
    //   162: invokestatic 198	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   165: aconst_null
    //   166: areturn
    //   167: astore 7
    //   169: aconst_null
    //   170: astore 6
    //   172: aload 7
    //   174: ifnull -100 -> 74
    //   177: aload 7
    //   179: invokevirtual 309	com/appwoo/android/exception/NotFoundNetWorkException:printStackTrace	()V
    //   182: ldc 65
    //   184: ldc_w 341
    //   187: invokestatic 198	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   190: aconst_null
    //   191: areturn
    //   192: astore 5
    //   194: aconst_null
    //   195: astore 6
    //   197: aload 5
    //   199: ifnull -125 -> 74
    //   202: aload 5
    //   204: invokevirtual 314	java/lang/Exception:printStackTrace	()V
    //   207: ldc 65
    //   209: ldc_w 343
    //   212: invokestatic 198	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   215: aconst_null
    //   216: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   43	52	77	java/lang/Exception
    //   55	70	92	java/io/IOException
    //   55	70	117	org/xmlpull/v1/XmlPullParserException
    //   55	70	142	com/appwoo/android/exception/TimeOutException
    //   55	70	167	com/appwoo/android/exception/NotFoundNetWorkException
    //   55	70	192	java/lang/Exception
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.RQKeepAlive
 * JD-Core Version:    0.6.2
 */